home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / tvx / part03 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  41.3 KB

  1. From: talcott!seismo!gatech!unmvax!wampler (Bruce Wampler)
  2. Subject: tvx: 3 of 10
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 17
  7. Submitted by: talcott!seismo!gatech!unmvax!wampler (Bruce Wampler)
  8.  
  9. #--------CUT---------CUT---------CUT---------CUT--------#
  10. #########################################################
  11. #  TVX: File 3 of 10                                    #
  12. #                                                       #
  13. # This is a shell archive file.  To extract files:      #
  14. #                                                       #
  15. #    1)    Make a directory (like tvx) for the files.      #
  16. #    2) Write a file, such as "filen.shar", containing  #
  17. #       this archive file into the directory.           #
  18. #    3) Type "sh file.shar".  Do not use csh.           #
  19. #                                                       #
  20. #########################################################
  21. #
  22. #
  23. echo Extracting Makefile:
  24. sed 's/^X//' >Makefile <<\SHAR_EOF
  25. X## Makefile for tvx
  26. XDEST          = .
  27. X
  28. XEXTHDRS          = /usr/include/ctype.h \
  29. X        /usr/include/sgtty.h \
  30. X        /usr/include/stdio.h \
  31. X        /usr/include/sys/ioctl.h \
  32. X        /usr/include/sys/types.h \
  33. X        /usr/include/sys/stat.h \
  34. X        /usr/include/sys/ttychars.h \
  35. X        /usr/include/sys/ttydev.h
  36. X
  37. XHDRS          = tvx_glbl.ic\
  38. X        tvx_defs.ic
  39. X
  40. XLDFLAGS          =
  41. X
  42. XCFLAGS        = -O\
  43. X        -DTVX_EM
  44. X
  45. XLIBS          = /usr/lib/libtermcap.a
  46. X
  47. XLINKER          = cc
  48. X
  49. XMAKEFILE      = Makefile
  50. X
  51. XOBJS          = tvx_unix.o \
  52. X        tvx_io.o \
  53. X        tvx_lex.o \
  54. X        tvx_1.o \
  55. X        tvx_2.o \
  56. X        tvx_edit.o \
  57. X        tvx_lib.o
  58. X
  59. XPRINT          = pr
  60. X
  61. XPROGRAM          = tvx
  62. X
  63. XSRCS          = tvx_unix.c \
  64. X        tvx_io.c \
  65. X        tvx_lex.c \
  66. X        tvx_1.c \
  67. X        tvx_2.c \
  68. X        tvx_edit.c \
  69. X        tvx_lib.c
  70. X
  71. Xall:        $(PROGRAM)
  72. X
  73. X$(PROGRAM):     $(OBJS) $(LIBS)
  74. X        @echo -n "Loading $(PROGRAM) ... "
  75. X        @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
  76. X        @echo "done"
  77. X
  78. Xclean:;        @rm -f $(OBJS)
  79. X
  80. Xdepend:;    @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
  81. X
  82. Xindex:;        @ctags -wx $(HDRS) $(SRCS)
  83. X
  84. Xinstall:    $(PROGRAM)
  85. X        @echo Installing $(PROGRAM) in $(DEST)
  86. X        @install -s $(PROGRAM) $(DEST)
  87. X
  88. Xprint:;        @$(PRINT) $(HDRS) $(SRCS)
  89. X
  90. Xprogram:        $(PROGRAM)
  91. X
  92. Xtags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
  93. X
  94. Xupdate:        $(DEST)/$(PROGRAM)
  95. X
  96. X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
  97. X        @make -f $(MAKEFILE) DEST=$(DEST) install
  98. X###
  99. Xtvx_unix.o: /usr/include/ctype.h /usr/include/sys/ioctl.h \
  100. X    /usr/include/sys/types.h /usr/include/sys/stat.h \
  101. X    /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
  102. X    /usr/include/sgtty.h /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  103. Xtvx_io.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  104. Xtvx_lex.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  105. Xtvx_1.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  106. Xtvx_2.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  107. Xtvx_edit.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  108. Xtvx_lib.o: /usr/include/stdio.h tvx_defs.ic
  109. X
  110. SHAR_EOF
  111. echo Extracting Makefile.sysV:
  112. sed 's/^X//' >Makefile.sysV <<\SHAR_EOF
  113. X## Makefile for tvx on System V
  114. XDEST          = .
  115. X
  116. XEXTHDRS          = /usr/include/ctype.h \
  117. X        /usr/include/sgtty.h \
  118. X        /usr/include/stdio.h \
  119. X        /usr/include/sys/ioctl.h \
  120. X        /usr/include/sys/types.h \
  121. X        /usr/include/sys/stat.h
  122. X
  123. XHDRS          = tvx_glbl.ic\
  124. X        tvx_defs.ic
  125. X
  126. XLDFLAGS          =
  127. X
  128. XCFLAGS        = -O\
  129. X        -DTVX_EM
  130. X
  131. XLIBS          = /usr/lib/libtermcap.a
  132. X
  133. XLINKER          = cc
  134. X
  135. XMAKEFILE      = Makefile.sysV
  136. X
  137. XOBJS          = tvx_unix.o \
  138. X        tvx_io.o \
  139. X        tvx_lex.o \
  140. X        tvx_1.o \
  141. X        tvx_2.o \
  142. X        tvx_edit.o \
  143. X        tvx_lib.o
  144. X
  145. XPRINT          = pr
  146. X
  147. XPROGRAM          = tvx
  148. X
  149. XSRCS          = tvx_unix.c \
  150. X        tvx_io.c \
  151. X        tvx_lex.c \
  152. X        tvx_1.c \
  153. X        tvx_2.c \
  154. X        tvx_edit.c \
  155. X        tvx_lib.c
  156. X
  157. Xall:        $(PROGRAM)
  158. X
  159. X$(PROGRAM):     $(OBJS) $(LIBS)
  160. X        @echo -n "Loading $(PROGRAM) ... "
  161. X        @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS)
  162. X         @cp a.out $(PROGRAM)
  163. X         @rm a.out
  164. X        @echo "done"
  165. X
  166. Xclean:;        @rm -f $(OBJS)
  167. X
  168. Xdepend:;    @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
  169. X
  170. Xindex:;        @ctags -wx $(HDRS) $(SRCS)
  171. X
  172. Xinstall:    $(PROGRAM)
  173. X        @echo Installing $(PROGRAM) in $(DEST)
  174. X        @install -s $(PROGRAM) $(DEST)
  175. X
  176. Xprint:;        @$(PRINT) $(HDRS) $(SRCS)
  177. X
  178. Xprogram:        $(PROGRAM)
  179. X
  180. Xtags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
  181. X
  182. Xupdate:        $(DEST)/$(PROGRAM)
  183. X
  184. X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
  185. X        @make -f $(MAKEFILE) DEST=$(DEST) install
  186. X###
  187. Xtvx_unix.o: /usr/include/ctype.h /usr/include/sys/ioctl.h \
  188. X    /usr/include/sys/types.h /usr/include/sys/stat.h \
  189. X    /usr/include/sgtty.h /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  190. Xtvx_io.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  191. Xtvx_lex.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  192. Xtvx_1.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  193. Xtvx_2.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  194. Xtvx_edit.o: /usr/include/stdio.h tvx_defs.ic tvx_glbl.ic
  195. Xtvx_lib.o: /usr/include/stdio.h tvx_defs.ic
  196. X
  197. SHAR_EOF
  198. echo Extracting tvx_make.bat:
  199. sed 's/^X//' >tvx_make.bat <<\SHAR_EOF
  200. XREM This is the batch file needed to compile and link the basic TVX using
  201. XREM Computer Innovations C-86 compiler.  If you have a different
  202. XREM compiler, you will have to make your own batch file.
  203. XREM     Once the basic TVX has been made, the other make batch files
  204. XREM     should be used to compile the appropriate modules for
  205. XREM    the other emulation versions if desired.
  206. XREM    This batch file assumes stdio.h is in a directory called \c\.
  207. XREM
  208. Xcc1 tvx_1 -hc:\c\
  209. Xcc2 tvx_1
  210. Xcc3 tvx_1
  211. Xcc4 tvx_1
  212. Xcc1 tvx_2 -hc:\c\
  213. Xcc2 tvx_2
  214. Xcc3 tvx_2
  215. Xcc4 tvx_2
  216. Xcc1 tvx_edit -hc:\c\
  217. Xcc2 tvx_edit
  218. Xcc3 tvx_edit
  219. Xcc4 tvx_edit
  220. Xcc1 tvx_lex -hc:\c\
  221. Xcc2 tvx_lex
  222. Xcc3 tvx_lex
  223. Xcc4 tvx_lex
  224. Xcc1 tvx_io -hc:\c\
  225. Xcc2 tvx_io
  226. Xcc3 tvx_io
  227. Xcc4 tvx_io
  228. Xcc1 tvx_lib -hc:\c\
  229. Xcc2 tvx_lib
  230. Xcc3 tvx_lib
  231. Xcc4 tvx_lib
  232. XREM
  233. XREM If you have in any way modified TVX_IBM.C, then it needs to be recompiled.
  234. XREM
  235. XREM cc1 tvx_ibm -hc:\c\
  236. XREM cc2 tvx_ibm
  237. XREM cc3 tvx_ibm
  238. XREM cc4 tvx_ibm
  239. XREM
  240. XREM Otherwise, use the following hand optimized version.  Some of the expensive
  241. XREM calls to sysint have been replaced with direct calls.  It is much faster
  242. XREM than the C version, and is the only case I've ever found that this is true.
  243. XREM
  244. Xmasm tvx_ibm;
  245. XREM
  246. XREM    Now, link the thing into a file called TVX.EXE
  247. XREM    It uses the CII small, DOS 2 library, which is called /c/cslib2
  248. XREM    on my system.  You may need to replace the library with whatever
  249. XREM    you call the corresponding library (like c86s2s.lib).
  250. XREM
  251. Xlink tvx_1+tvx_2+tvx_edit+tvx_lex+tvx_io+tvx_lib+tvx_ibm,tvx,nul:,/c/cslib2
  252. XREM
  253. XREM    Build the patch / configuration utilities
  254. XREM
  255. Xcc1 tvx_cfg -hc:\c\
  256. Xcc2 tvx_cfg
  257. Xcc3 tvx_cfg
  258. Xcc4 tvx_cfg
  259. Xlink tvx_cfg,tvx_cfg,nul:,/c/cslib2
  260. Xcc1 tvx_ptch -hc:\c\
  261. Xcc2 tvx_ptch
  262. Xcc3 tvx_ptch
  263. Xcc4 tvx_ptch
  264. Xlink tvx_ptch,tvx_ptch,nul:,/c/cslib2
  265. XREM
  266. XREM    Build of tvx finished
  267. XREM
  268. SHAR_EOF
  269. echo Extracting atari.info:
  270. sed 's/^X//' >atari.info <<\SHAR_EOF
  271. X#------------------------- ATARI SPECIAL FILES -------------------------
  272. X    This file contains some extra files needed to compile and use
  273. XTVX on the Atari 520st.  These files are included in this one file.
  274. XYou will have to split it apart yourself.  The files assume you have
  275. Xthe developers kit, and include:
  276. X
  277. X    HIRES.S - the assembly source of the 25/50 line screen interface
  278. X        RES25PRG.S - assembly source of PROGRAM to change to 25 lines
  279. X    RES50PRG.S - assembly source of PROGRAM to change to 50 lines
  280. X        { Just assemble and link/relmod these, no libraries needed }
  281. X        These are needed because TVX allows you to switch to a 50
  282. X        line display ('(' command), but doesn't force it back to
  283. X        25 when it exits (maybe you want to stay in 50!).  Having
  284. X        the programs allows you to switch back to 25 outside of
  285. X        TVX.
  286. X    STDIOTVX.H - fixed up version of stdio.h to avoid portab.h problems.
  287. X    CTVX.BAT - Batch file to compile all modules of TVX. Assumes
  288. X        the compiler is in A:, TVX source in B:, and the
  289. X        batch file run from B: (e.g. {B}a:batch ctvx).
  290. X        (If you build VIX or EMAX, you only need to recompile
  291. X         the TVX_EDIT and TVX_LEX modules, after changing the ifdefs)
  292. X        Be patient, it takes over an hour to compile on floppies.
  293. X    LINKTVX.BAT - file to link tvx.  Assumes .o's on B:, run from a:.
  294. X
  295. X#-------------------- cut here, save as HIRES.S -------------------------
  296. X*  Make hi rez screen bios handle 25 lines of 8x16 characters
  297. X*
  298. X        .text
  299. X        .globl _rez25
  300. XLINEA_I        equ    $A000 
  301. XGET_REZ        equ    4        ; extended bios resolution inquiry
  302. X_rez25: 
  303. X    link    R14,#-4            ; set up
  304. X    move.w    #GET_REZ,-(sp)        ; get screen resolution
  305. X    trap    #14 
  306. X    addq.w    #2,sp
  307. X    cmp.w    #2,d0            ; only execute if already in hi rez
  308. X    bne    ex25f 
  309. X    dc.w    LINEA_I            ; get the important pointers 
  310. X    move.l    08(a1),a1        ; a1 -> 8x16 font header 
  311. X    move.l    72(a1),-$0A(a0)        ; v_off_ad <- 8x16 offset table ad
  312. X    move.l    76(a1),-$16(a0)        ; v_fnt_ad <- 8x16 font data addr 
  313. X    move.w    #0016,-$2E(a0)        ; v_cel_ht <- 16  8x16 cell heigh
  314. X    move.w    #0024,-$2A(a0)        ; v_cel_my <- 24  maximum cell "Y" 
  315. X    move.w    #1280,-$28(a0)        ; v_cel_wr <- 1280  vertical byte offset
  316. X    move    #1,R0            ; true return
  317. X    bra    ex25
  318. Xex25f:
  319. X    move    #0,R0            ; false return
  320. Xex25:    unlk    R14            ; prepare for return
  321. X    rts
  322. X*
  323. X*  Make hi rez screen bios handle 50 lines of 8x8 characters
  324. X*
  325. X        .globl _rez50
  326. X_rez50: 
  327. X    link    R14,#-4            ; set up
  328. X    move.w    #GET_REZ,-(sp)        ; get screen resolution
  329. X    trap    #14 
  330. X    addq.w    #2,sp
  331. X    cmp.w    #2,d0            ; only execute if already in hi rez
  332. X    bne    ex50f 
  333. X    dc.w    LINEA_I            ; get the important pointers 
  334. X    move.l    04(a1),a1        ; a1 -> 8x8 font header 
  335. X    move.l    72(a1),-$0A(a0)        ; v_off_ad <- 8x8 offset table ad
  336. X    move.l    76(a1),-$16(a0)        ; v_fnt_ad <- 8x8 font data addr 
  337. X    move.w    #008,-$2E(a0)        ; v_cel_ht <- 8  8x8 cell heigh
  338. X    move.w    #0049,-$2A(a0)        ; v_cel_my <- 49  maximum cell "Y" 
  339. X    move.w    #640,-$28(a0)        ; v_cel_wr <- 640  vertical byte offset
  340. X    move    #1,R0            ; true return
  341. X    bra    ex50
  342. Xex50f:
  343. X    move    #0,R0            ; false return
  344. Xex50:    unlk    R14            ; prepare for return
  345. X    rts
  346. X    .data
  347. X    end 
  348. X#-------------------- cut here, save as RES25PRG.S -------------------------
  349. X*
  350. X*  Make hi rez screen bios handle 25 lines of 8x16 characters
  351. X*
  352. X*  Simply as68 this, then link it, no libraries needed
  353. X        .text
  354. X        .globl _hi25
  355. XLINEA_I        equ     $A000 
  356. XGET_REZ        equ     4           ; extended bios resolution inquiry
  357. X_hi25: 
  358. X    lea     stack,sp 
  359. X    move.w  #GET_REZ,-(sp)      ; get screen resolution
  360. X    trap    #14 
  361. X    addq.w  #2,sp
  362. X    cmp.w   #2,d0               ; only execute if already in hi rez
  363. X    bne     exit 
  364. X    dc.w    LINEA_I          ; get the important pointers 
  365. X    move.l  08(a1),a1           ; a1 -> 8x16 font header 
  366. X    move.l  72(a1),-$0A(a0)     ; v_off_ad <- 8x16 offset table ad
  367. X    move.l  76(a1),-$16(a0)     ; v_fnt_ad <- 8x16 font data addr 
  368. X    move.w  #0016,-$2E(a0)      ; v_cel_ht <- 16    8x16 cell heigh
  369. X    move.w  #0024,-$2A(a0)      ; v_cel_my <- 24    maximum cell "Y" 
  370. X    move.w  #1280,-$28(a0)      ; v_cel_wr <- 1280  vertical byte offset
  371. Xexit:   clr.w   -(sp)               ; back to the os 
  372. X    trap    #1 
  373. X    ds.l    $10
  374. Xstack:  ds.l    $01                 ; hey chef, gimme a short stack
  375. X    end 
  376. X#-------------------- cut here, save as RES50PRG.S -------------------------
  377. X*
  378. X*  Make hi rez screen bios handle 25 lines of 8x16 characters
  379. X*
  380. X*  Simply as68 this, then link it, no libraries needed
  381. X*
  382. X        .text
  383. X        .globl _hi50
  384. XLINEA_I        equ     $A000 
  385. XGET_REZ        equ     4           ; extended bios resolution inquiry
  386. X_hi50: 
  387. X    lea     stack,sp 
  388. X    move.w  #GET_REZ,-(sp)      ; get screen resolution
  389. X    trap    #14 
  390. X    addq.w  #2,sp
  391. X    cmp.w   #2,d0               ; only execute if already in hi rez
  392. X    bne     exit 
  393. X    dc.w    LINEA_I          ; get the important pointers 
  394. X    move.l  04(a1),a1           ; a1 -> 8x8 font header 
  395. X    move.l  72(a1),-$0A(a0)     ; v_off_ad <- 8x8 offset table ad
  396. X    move.l  76(a1),-$16(a0)     ; v_fnt_ad <- 8x8 font data addr 
  397. X    move.w  #008,-$2E(a0)        ; v_cel_ht <- 8    8x8 cell heigh
  398. X    move.w  #0049,-$2A(a0)      ; v_cel_my <- 49    maximum cell "Y" 
  399. X    move.w  #640,-$28(a0)        ; v_cel_wr <- 640  vertical byte offset
  400. Xexit:   clr.w   -(sp)               ; back to the os 
  401. X    trap    #1 
  402. X    ds.l    $10
  403. Xstack:  ds.l    $01                 ; hey chef, gimme a short stack
  404. X    end 
  405. X#-------------------- cut here, save as STDIOTVX.H -------------------------
  406. X/* stdio.h fixed to make it compatible with the rest of the world */
  407. X
  408. X#define mc68k 0
  409. X
  410. X#define TRUE 1
  411. X#define FALSE 0
  412. X
  413. X#define    NULL    0
  414. X#define NULLPTR (char *) 0
  415. X#define    EOF    (-1)
  416. X
  417. X#define BUFSIZ    512
  418. X#define MAXFILES    16
  419. Xstruct _iobuf {    
  420. X    int _fd;
  421. X    int _flag;
  422. X    char *_base;
  423. X    char *_ptr;
  424. X    int _cnt;
  425. X};
  426. X
  427. X#ifndef FILE
  428. Xextern struct _iobuf _iob[MAXFILES];
  429. X#define FILE struct _iobuf
  430. X#endif
  431. X#define NULLFILE ((FILE *)0)
  432. X
  433. X#define _IOREAD    0x01
  434. X#define _IOWRT    0x02
  435. X#define _IOABUF    0x04
  436. X#define _IONBUF    0x08
  437. X#define _IOERR    0x10
  438. X#define _IOEOF    0x20
  439. X#define _IOLBUF 0x40
  440. X#define _IOSTRI    0x80
  441. X#define _IOASCI    0x100
  442. X
  443. X#define stdin  (&_iob[0])
  444. X#define stdout (&_iob[1])
  445. X#define stderr (&_iob[2])
  446. X
  447. X#define clearerr(p) ((p)->_flag &= ~_IOERR)
  448. X#define feof(p) ((p)->_flag & _IOEOF)
  449. X#define ferror(p) ((p)->_flag & _IOERR)
  450. X#define fileno(p) ((p)->_fd)
  451. X#define getchar() getc(stdin)
  452. X#define putchar(c) putc(c,stdout)
  453. X#define putc fputc
  454. X#define getc fgetc
  455. X
  456. X
  457. X#define    abs(x)    ((x) < 0 ? -(x) : (x))
  458. X
  459. X#define MAX(x,y)   (((x) > (y)) ? (x) :  (y))
  460. X#define    MIN(x,y)   (((x) < (y)) ? (x) :  (y))
  461. X#define max(x,y)   (((x) > (y)) ? (x) :  (y))
  462. X#define    min(x,y)   (((x) < (y)) ? (x) :  (y))
  463. X
  464. X/*************************** end of stdio.h *********************************/
  465. X#-------------------- cut here, save as CTVX.BAT -------------------------
  466. Xa:as68 -l -u -s a: b:hires.s
  467. Xa:cp68 -p -I A: tvx_1.c tvx_1.i
  468. Xa:c068 tvx_1.i tvx_1.1 tvx_1.2 tvx_1.3 -f
  469. Xa:rm tvx_1.i
  470. Xa:c168 tvx_1.1 tvx_1.2 tvx1.s
  471. Xa:rm tvx_1.1
  472. Xa:rm tvx_1.2
  473. Xa:as68 -l -u -s a: b:tvx1.s
  474. Xa:rm b:tvx1.s
  475. Xa:cp68 -p -I A: tvx_2.c tvx_2.i
  476. Xa:c068 tvx_2.i tvx_2.1 tvx_2.2 tvx_2.3 -f
  477. Xa:rm tvx_2.i
  478. Xa:c168 tvx_2.1 tvx_2.2 tvx2.s
  479. Xa:rm tvx_2.1
  480. Xa:rm tvx_2.2
  481. Xa:as68 -l -u -s a: b:tvx2.s
  482. Xa:rm b:tvx2.s
  483. Xa:cp68 -p -I A: tvx_io.c tvx_io.i
  484. Xa:c068 tvx_io.i tvx_io.1 tvx_io.2 tvx_io.3 -f
  485. Xa:rm tvx_io.i
  486. Xa:c168 tvx_io.1 tvx_io.2 tvxio.s
  487. Xa:rm tvx_io.1
  488. Xa:rm tvx_io.2
  489. Xa:as68 -l -u -s a: b:tvxio.s
  490. Xa:rm b:tvxio.s
  491. Xa:cp68 -p -I A: tvx_lib.c tvx_lib.i
  492. Xa:c068 tvx_lib.i tvx_lib.1 tvx_lib.2 tvx_lib.3 -f
  493. Xa:rm tvx_lib.i
  494. Xa:c168 tvx_lib.1 tvx_lib.2 tvxlib.s
  495. Xa:rm tvx_lib.1
  496. Xa:rm tvx_lib.2
  497. Xa:as68 -l -u -s a: b:tvxlib.s
  498. Xa:rm b:tvxlib.s
  499. Xa:cp68 -p -I A: tvx_edit.c tvx_edit.i
  500. Xa:c068 tvx_edit.i tvx_edit.1 tvx_edit.2 tvx_edit.3 -f
  501. Xa:rm tvx_edit.i
  502. Xa:c168 tvx_edit.1 tvx_edit.2 tvxedit.s
  503. Xa:rm tvx_edit.1
  504. Xa:rm tvx_edit.2
  505. Xa:as68 -l -u -s a: b:tvxedit.s
  506. Xa:rm b:tvxedit.s
  507. Xa:cp68 -p -I A: tvx_lex.c tvx_lex.i
  508. Xa:c068 tvx_lex.i tvx_lex.1 tvx_lex.2 tvx_lex.3 -f
  509. Xa:rm tvx_lex.i
  510. Xa:c168 tvx_lex.1 tvx_lex.2 tvxlex.s
  511. Xa:rm tvx_lex.1
  512. Xa:rm tvx_lex.2
  513. Xa:as68 -l -u -s a: b:tvxlex.s
  514. Xa:rm b:tvxlex.s
  515. X#-------------------- cut here, save as LINKTVX.BAT -------------------------
  516. Xlink68 [u] B:tvx.68k=gems,b:tvx1,b:tvx2,b:tvxedit,b:tvxlex,b:tvxio,b:tvxlib,b:hires,osbind,gemlib
  517. Xrelmod b:tvx
  518. Xrm b:tvx.68K
  519. X#-------------------- END OF ATARI SPECIAL FILES -------------------------
  520. X
  521. SHAR_EOF
  522. echo Extracting tvx_ibm.c:
  523. sed 's/^X//' >tvx_ibm.c <<\SHAR_EOF
  524. X/* ------------------------- tvx_ibm.c -------------------------- */
  525. X/*
  526. X    This is the interface to the PC's ROM BIOS.  It could
  527. X    be bypassed by using the ANSI.SYS driver, but that would
  528. X    be SLOW!  This version is cii-c86 dependent, mainly using
  529. X    the routine sysint, for example:
  530. X          sysint(0x10, &rin, &rout);
  531. X        int. number^     ^registers in and out
  532. X    If possible, these calls should be replaced with direct
  533. X    assembly language calls.  The overhead of sysint is high
  534. X    and noticeably slows down screen update.
  535. X*/
  536. X
  537. X#define FALSE 0
  538. X#define TRUE 1
  539. X/*    Interface to IBM ROM BIOS INT10 screen control.  Following
  540. X    control codes are defined:
  541. X
  542. X    ^@,0    ^A,1    ^B,2    ^C,3
  543. X    other, erslin, erseos, inslin
  544. X    ^D,4    ^E,5    ^F,6    ^G,7
  545. X    undlon, undloff, dellin, bell
  546. X    ^H,8    ^I,9    ^J,10    ^K,11
  547. X    backsp,    tab, linefeed, boldon
  548. X    ^L,12    ^M,13    ^N,14    ^O,15
  549. X    boldoff, enter, reversoff, blinkoff
  550. X    ^P,16    ^Q,17    ^R,18    ^S,19, ^T,20
  551. X    reverson, blinkon, setxy, cursor1, initcursor
  552. X */
  553. X#define m_normal 07    /* white on black */
  554. X#define m_underline 01    /* normal, underlined */
  555. X#define m_reverse 0x70
  556. X#define m_dim 0xF7    /* dim display */
  557. X#define m_bright 0x08    /* bright display */
  558. X#define m_blink    0x80    /* blink for errors */
  559. X#define m_noblink 0x7F
  560. X
  561. X
  562. X/* ============================ dispch ============================== */
  563. X  dispch(chin)
  564. X  int chin;
  565. X  {
  566. X
  567. X    static int ch;
  568. X    struct regval
  569. X      {
  570. X    unsigned int ax;
  571. X    unsigned int bx;
  572. X    unsigned int cx;
  573. X    unsigned int dx;
  574. X    unsigned int si;
  575. X    unsigned int di;
  576. X    unsigned int ds;
  577. X    unsigned int es;
  578. X      };
  579. X    struct regval rin, rout;
  580. X
  581. X    /* data structures for screen control */
  582. X    static int ich;
  583. X    static int maxcol = 79;        /*  max col, counting from 0 */
  584. X    static int savechar;
  585. X    static int initflg = FALSE;
  586. X    static int curpage = 0;        /* current display page (internal) */
  587. X    static int curmode = 7;        /* white on black */
  588. X    static int curcol;            /* col and row, preserve this order */
  589. X    static int currow;            /* so can load in one instruction */
  590. X    static int curstate = 0;        /* 0: accepting chars
  591. X                       1: waiting for row
  592. X                       2: waiting for col */
  593. X    static int rowpend = 0;        /* to save pending row */
  594. X    static int initcursor;        /* initial cursor */
  595. X    static int altcursor;
  596. X    static int color;        /* mono or color */
  597. X
  598. X    ch = chin & 0xff;
  599. X
  600. X    if (!initflg)
  601. X      {
  602. X    rin.ax = 0x0F00;        /* ah is 15, get video state */
  603. X    sysint(0x10, &rin, &rout);    /* int 10h */
  604. X    maxcol = ((rout.ax >> 8) & 0xff) - 1;    /* make relative value (0-79) */
  605. X      curpage = (rout.bx >> 8) & 0xff;    /* the active page */
  606. X    rin.ax = 0x0300;        /* read cursor position */
  607. X    sysint(0x10, &rin, &rout);    /* int 10h */
  608. X    curcol = rout.dx & 0xff;    /* low order is col */
  609. X    currow = (rout.dx >> 8) & 0xff;
  610. X    sysint(0x11,&rin,&rout);    /* get system configuration */
  611. X    color = (rout.ax & 0x30) != 0x30;
  612. X    if (!color)
  613. X      {
  614. X        initcursor = 0x0c0d;    /* 12, 13 - avoids PC ROM bug! */
  615. X        altcursor = 0x060d;        /* 6,13 for insert */
  616. X      }
  617. X    else
  618. X      {
  619. X        initcursor = 0x0607;    /* current cursor mode, color */
  620. X        altcursor = 0x0307;        /* half block */
  621. X      }
  622. X    initflg = TRUE;
  623. X      }
  624. X
  625. X
  626. X    if (curstate != 0)        /* waiting for row or col? */
  627. X      {
  628. X    if (curstate == 1)
  629. X      {
  630. X        /* in state 1, so this is row */
  631. X        rowpend = ch;        /* save pending row */
  632. X        curstate = 2;        /* now in wait state */
  633. X        return;
  634. X      }
  635. X    else        /* waiting for column */
  636. X      {
  637. X        ich = ch - ' ';    /* convert to absolute */
  638. X        if (ich > maxcol)
  639. X        ich = maxcol;
  640. X        curcol = ich;    /* remember column */
  641. X        rowpend -= ' ';    /* convert row */
  642. X        if (rowpend > 24)
  643. X        rowpend = 24;
  644. X        currow = rowpend;
  645. X        rin.dx = (currow << 8) | curcol;
  646. X        rin.bx = curpage << 8;
  647. X        rin.ax = 0x200;    /* 2 => set cursor */
  648. X        sysint(0x10, &rin, &rout);    /* int 10h */
  649. X        curstate = 0;
  650. X        return;
  651. X      }
  652. X      }
  653. X    else
  654. X      {
  655. X    if (ch >= ' ')
  656. X        goto SHOWCHAR;    /* slight optimization */
  657. X
  658. X    switch (ch)
  659. X      {
  660. X        case 1:        /* erase from cursor to end of line */
  661. Xerslin:
  662. X        rin.cx = rin.dx = currow << 8;        /* set row */
  663. X        rin.cx |= curcol;        /* set col */
  664. X        rin.dx |= maxcol;        /* blank to max col */
  665. X        rin.ax = 0x600;          /* scroll active page up, blank section */
  666. X        rin.bx = curmode << 8;
  667. X        sysint(0x10, &rin, &rout);    /* int 10h */
  668. X        return;
  669. X
  670. X        case 2:        /* erase from cursor to end of screen */
  671. X        /* first, earase current row */
  672. X        rin.cx = rin.dx = currow << 8;        /* set row */
  673. X        rin.cx |= curcol;        /* set col */
  674. X        rin.dx |= maxcol;        /* blank to max col */
  675. X        rin.ax = 0x600;          /* scroll active page up, blank section */
  676. X        rin.bx = curmode << 8;
  677. X        sysint(0x10, &rin, &rout);    /* int 10h */
  678. X        if (currow >= 24)    /* on bottom row now? */
  679. X            return;
  680. X        rin.cx = (currow + 1) << 8;     /* next row, col 0 */
  681. X        rin.dx = 0x1800 | maxcol;
  682. X        rin.ax = 0x0600;        /* 6: scroll 0: blank */
  683. X        sysint(0x10, &rin, &rout);    /* int 10h */
  684. X        return;
  685. X
  686. X        case 3:        /* insert a blank line at cursor */
  687. X        if (currow < 24)
  688. X          {
  689. X            rin.cx = (currow << 8);
  690. X            rin.dx = 0x1800 | maxcol;    /* define window to scroll */
  691. X            rin.bx = curmode << 8;
  692. X            rin.ax = 0x0701;        /* one line, scroll down */
  693. X            sysint(0x10, &rin, &rout);    /* int 10h */
  694. X          }
  695. X        curcol = 0;        /* home to line beginning */
  696. X        rin.dx = currow << 8;    /* dh = currow, dl = 0 */
  697. X        rin.bx = curpage << 8;
  698. X        rin.ax = 0x0200;    /* reset cursor position */
  699. X        sysint(0x10, &rin, &rout);    /* int 10h */
  700. X        if (currow >= 24)    /* special case */
  701. X            goto erslin;
  702. X        return;
  703. X
  704. X        case 4:        /* underline on */
  705. X        curmode = (curmode & 0x88) | m_underline;
  706. X        return;
  707. X
  708. X        case 5:        /* underline off */
  709. X        curmode = (curmode & 0x88) | m_normal;
  710. X        return;
  711. X
  712. X        case 6:            /*  kill line cursor is on */
  713. X        rin.cx = currow << 8;    /* define window to scroll */
  714. X        rin.dx = 0x1800 | maxcol;
  715. X        rin.ax = 0x0601;        /* one line (al), scroll up (6) */
  716. X        rin.bx = curmode << 8;
  717. X        sysint(0x10, &rin, &rout);    /* int 10h */
  718. X        curcol = 0 ;        /* home to line beginning */
  719. X        rin.dx = currow << 8;
  720. X        rin.bx = curpage << 8;
  721. X        rin.ax = 0x0200;
  722. X        sysint(0x10, &rin, &rout);    /* int 10h */
  723. X        return;
  724. X
  725. X        case 7:        /* bell */
  726. X        bdos(2,ch);
  727. X        return;
  728. X
  729. X        case 8:        /* backspace */
  730. X        if (curcol <= 0)
  731. X            return;
  732. X        --curcol;
  733. X        rin.bx = curpage << 8;
  734. X        rin.dx = (currow << 8) | curcol;
  735. X        rin.ax = 0x0200;    /* set cursor pos */
  736. X        sysint(0x10, &rin, &rout);    /* int 10h */
  737. X        return;
  738. X
  739. X        case 9:        /* tab */
  740. X        ch = ' ';
  741. X        goto SHOWCHAR;
  742. X
  743. X        case 10:        /* line feed, scroll if bottom */
  744. X        if (currow < 24)
  745. X          {
  746. X            rin.dx = (++currow << 8) | curcol;
  747. X            rin.bx = curpage << 8;
  748. X            rin.ax = 0x0200;        /* set cursor */
  749. X            sysint(0x10, &rin, &rout);    /* int 10h */
  750. X          }
  751. X        else
  752. X          {
  753. X            /* need to scroll up */
  754. X            rin.ax = 0x0601;    /* scroll up (6) 1 line (1) */
  755. X            rin.cx = 0;        /* upper right */
  756. X            rin.dx = 0x1800 | maxcol;
  757. X            rin.bx = curmode << 8;
  758. X            sysint(0x10, &rin, &rout);    /* int 10h */
  759. X          }
  760. X        return;
  761. X
  762. X        case 11:        /* bold on */
  763. X        curmode |= m_bright;
  764. X        return;
  765. X
  766. X        case 12:        /* bold off */
  767. X        curmode &= m_dim;
  768. X        return;
  769. X
  770. X        case 13:        /* CR, include erase end of line */
  771. X        if (curcol >= maxcol)
  772. X            goto NOBLANK;
  773. X        rin.cx = rin.dx = currow << 8;        /* set row */
  774. X        rin.cx |= curcol;        /* set col */
  775. X        rin.dx |= maxcol;        /* blank to max col */
  776. X        rin.ax = 0x0600;    /* scroll up, blank section */
  777. X        rin.bx = curmode << 8;
  778. X        sysint(0x10, &rin, &rout);    /* int 10h */
  779. XNOBLANK:
  780. X        curcol = 0;
  781. X            rin.dx = (currow << 8);
  782. X        rin.bx = curpage << 8;
  783. X        rin.ax = 0x0200;
  784. X        sysint(0x10, &rin, &rout);    /* int 10h */
  785. X        return;
  786. X
  787. X        case 14:        /* reverse off */
  788. X        curmode = (curmode & 0x88) | m_normal ;
  789. X        return;
  790. X
  791. X        case 15:        /* blink off */
  792. X        curmode &= m_noblink;
  793. X        return;
  794. X
  795. X        case 16:        /* reverse on */
  796. X        curmode = (curmode & 0x88) | m_reverse;
  797. X        return;
  798. X
  799. X        case 17:        /* blink on */
  800. X        curmode |= m_blink;
  801. X        return;
  802. X
  803. X        case 18:        /* set xy */
  804. X        curstate = 1;
  805. X        return;
  806. X
  807. X        case 19:            /* change cursor */
  808. X        rin.ax = 0x0100;    /* set cursor type */
  809. X        rin.cx = altcursor;    /* half block */
  810. X        sysint(0x10, &rin, &rout);
  811. X        return;
  812. X
  813. X        case 20:            /* change cursor */
  814. X        rin.ax = 0x0100;    /* set cursor type */
  815. X        rin.cx = initcursor;    /* original */
  816. X        sysint(0x10, &rin, &rout);
  817. X        return;
  818. X
  819. X
  820. X        default:        /* show char */
  821. XSHOWCHAR:
  822. X        if (curcol > maxcol)    /* update column */
  823. X            return;
  824. X        rin.ax = 0x0900 | ch;        /* display char */
  825. X        rin.bx = (curpage << 8) | curmode;
  826. X        rin.cx = 1;
  827. X        sysint(0x10, &rin, &rout);    /* int 10h */
  828. X        ++curcol;
  829. X        rin.dx = (currow << 8) | curcol;
  830. X        rin.ax = 0x0200;
  831. X        sysint(0x10, &rin, &rout);    /* int 10h */
  832. X        return;
  833. X      }    /* end of switch */
  834. X      }        /* end of else */
  835. X  }
  836. SHAR_EOF
  837. echo Extracting tvx_unix.c:
  838. sed 's/^X//' >tvx_unix.c <<\SHAR_EOF
  839. X/* -------------------------- tvx_unix.c ------------------------------ */
  840. X#include "tvx_defs.ic"
  841. X#include "tvx_glbl.ic"
  842. X
  843. X#ifdef SYSV
  844. X#undef VQUIT            /* name conflict with sys V - irrelevant
  845. X                name in tvx_unix.c */
  846. X#include <termio.h>
  847. X#endif
  848. X
  849. X#define TEMPEXT ".$$1"        /* temporary file */
  850. X#define BACKEXT ".B"        /* backup file */
  851. X#define SWITCH '-'
  852. X#define FILESEP '.'
  853. X
  854. X/* define USETMP if you want intermediate workfiles built on
  855. X   /tmp.  Otherwise, they will be built on the same directory as
  856. X   the original file.  This latter method is often a bit faster,
  857. X   especially when exiting if /tmp is on a different volume than
  858. X   the destination file (which makes mv COPY the file rather than
  859. X   just renameing. */
  860. X
  861. X/* #define USETMP */            /* define if create temp files on /tmp */
  862. X
  863. X#include <ctype.h>
  864. X#include <sys/ioctl.h>
  865. X#include <sys/types.h>
  866. X
  867. X#ifdef ULTRIX11
  868. X#include <sgtty.h>
  869. X#endif
  870. X
  871. X#ifdef SCR_BUF
  872. Xchar *Scrbuf;                   /* Base address of screen buffer. */
  873. Xchar *Scrptr;                   /* Dynamic screen buffer pointer. */
  874. X#endif
  875. X/* --------------  terminal I/O stuff --------------- */
  876. X
  877. X#ifdef SYSV
  878. Xstatic struct termio sgb;
  879. X#else
  880. Xstatic struct sgttyb sgb;
  881. Xstatic struct tchars tch;
  882. Xstatic struct ltchars ltc;
  883. X#endif
  884. X
  885. X#define Ioctl ioctl
  886. X#define Read read
  887. X#define Write write
  888. X
  889. X/* ------------- file mode stuff ---------------------- */
  890. X#include <sys/stat.h>
  891. X  static struct stat info;        /* structure to get info */
  892. X
  893. X/* ------------- misc stuff ---------------------- */
  894. X
  895. X  extern int errno;
  896. X  extern char **environ;
  897. X
  898. X
  899. X#ifdef TERMCAP            /* routines needed for termcap */
  900. X/* ------------- termcap stuff ---------------------- */
  901. X  char PC;
  902. X  char *BC;
  903. X  char *UP;
  904. X  char TERM[40];
  905. X  short ospeed;
  906. X
  907. X  static char Tcm[80];        /* special entry for cm */
  908. X  static char empty[2];
  909. X  static char Tbc[20];
  910. X  static char Tup[20];
  911. X
  912. X  static int    Tco,            /* number of columns per line */
  913. X        Tli;            /* number of lines */
  914. X
  915. X  static char tcbuff[1024];        /* buffer to hold termcap entry */
  916. X
  917. X/* ==========================>>> gettermcap  <<<========================= */
  918. X  gettermcap()
  919. X  {
  920. X    char *tp;
  921. X    char *getenv();
  922. X    char entry[80];        /* scratch buffer for entry */
  923. X
  924. X    empty[0] = 0;
  925. X
  926. X#ifdef SYSV
  927. X    ospeed = sgb.c_cflag & CBAUD;
  928. X#else
  929. X    ospeed = sgb.sg_ospeed;    /* get the speed */
  930. X#endif
  931. X
  932. X    if ((tp = getenv("TERM")) == NULL)
  933. X      {
  934. X    goto FORCETTY;
  935. X      }
  936. X    strcpy(TERM,tp);        /* copy to our TERM */
  937. X
  938. X    if (tgetent(tcbuff,TERM) < 1)
  939. X      {
  940. X    goto FORCETTY;
  941. X      }
  942. X
  943. X/*    read required termcap entries, save in appropriate TVX arrays */
  944. X
  945. X    if (!gettcap("cm",Tcm))
  946. X      {
  947. X    goto FORCETTY;
  948. X      }
  949. X
  950. X    if (!gettcap("ce",entry))
  951. X      {
  952. X    goto FORCETTY;
  953. X      }
  954. X    if (!capcpy(celin,entry,7))    /* copy entry to end of line */
  955. X      {
  956. X    goto FORCETTY;
  957. X      }
  958. X    
  959. X    if (tgetflag("da"))
  960. X    dsp_mem = TRUE;            /* display has memory */
  961. X    else if (tgetflag("db"))
  962. X    dsp_mem = TRUE;
  963. X
  964. X    gettcap("cd",entry);        /* clear to end of display */
  965. X    capcpy(cescr,entry,7);
  966. X
  967. X    gettcap("al",entry);        /* insert a line (add line) */
  968. X    capcpy(ciline,entry,7);
  969. X
  970. X    gettcap("dl",entry);    /* delete a line */
  971. X    capcpy(ckline,entry,7);
  972. X
  973. X    if (!gettcap("sr",entry))    /* reverse scroll */
  974. X      {
  975. X    strcpy(ctopb,ciline);    /* add line works the same */
  976. X      }
  977. X    else
  978. X    capcpy(ctopb,entry,7);
  979. X
  980. X    gettcap("dc",entry);        /* delete character */
  981. X    capcpy(cdelchr,entry,7);
  982. X    gettcap("cl",entry);        /* clear screen */
  983. X    capcpy(cclears,entry,7);
  984. X
  985. X
  986. X    gettcap("ve",entry);        /* stand cursor changer end */
  987. X    capcpy(ccsrcm,entry,7);
  988. X    gettcap("vs",entry);        /* stand cursor changer begin */
  989. X    capcpy(ccsrin,entry,7);
  990. X
  991. X    gettcap("se",entry);        /* stand out end */
  992. X    capcpy(cbolde,entry,7);
  993. X
  994. X    gettcap("so",entry);        /* begin standout */
  995. X    capcpy(cboldb,entry,7);
  996. X
  997. X    cerred[0] = 7;                /* bell for sure */
  998. X    gettcap("vb",entry);        /* visual bell? */
  999. X    if (*entry)
  1000. X    capcpy(cerred,entry,7);
  1001. X
  1002. X    if (!capcpy(&cversn[1],TERM,10))        /* copy name to version */
  1003. X    strcpy(cversn,"TERMCAP");
  1004. X
  1005. X    if ((Tco = tgetnum("co")) < 0)    /* # of cols */
  1006. X    Tco = 79;        /* assume 80 x 24 */
  1007. X    if ((Tli = tgetnum("li")) < 0)    /* # of lines */
  1008. X    Tli = 24;        /* assume 80 x 24 */
  1009. X
  1010. X    tvhardlines = tvlins = Tli;    /* number of lines */
  1011. X    tvcols = Tco - 1; /* set col val (-1 avoids all the line wrap crap )*/
  1012. X    if (tvhardlines != 24 || tvhardlines != 25)    /* strange terminal */
  1013. X      {
  1014. X    ddline = (tvlins / 2) + 1;
  1015. X    setdscrl();        /* calculate scroll */
  1016. X      }
  1017. X
  1018. X    gettcap("bc",entry);        /* get backspace character */
  1019. X    if (!*entry)
  1020. X      {
  1021. X    Tbc[0] = 8; Tbc[1] = 0;
  1022. X      }
  1023. X    else
  1024. X    capcpy(Tbc,entry,19);
  1025. X    BC = Tbc;
  1026. X    gettcap("up",entry);        /* get backspace character */
  1027. X    if (!*entry)
  1028. X      {
  1029. X    Tup[0] = 0;
  1030. X      }
  1031. X    else
  1032. X    capcpy(Tup,entry,19);
  1033. X    UP = Tup;
  1034. X    gettcap("pc",entry);        /* get the pad character */
  1035. X    PC = *entry;
  1036. X
  1037. X#ifdef USE_TC_is
  1038. X    gettcap("is",entry);        /* initialization string */
  1039. X    tcapcs(entry);            /* send the intialization string */
  1040. X#endif
  1041. X
  1042. X    gettcap("ti",entry);        /* cm initialization string */
  1043. X    tcapcs(entry);            /* send the intialization string */
  1044. X
  1045. X    return;
  1046. X
  1047. XFORCETTY:
  1048. X   reset();
  1049. X   remark("");
  1050. X   remark("Unable to set up for video terminal, try again with -t switch.");
  1051. X   exit(999);
  1052. X  }
  1053. X
  1054. X/* =============================>>> capcpy  <<<============================= */
  1055. X  capcpy(to,from,len)
  1056. X  char *to, *from;
  1057. X  int len;
  1058. X  {        /* copy a capability, checking length */
  1059. X    if (strlen(from) > len)
  1060. X      {
  1061. X    *to = 0;
  1062. X    return (FALSE);
  1063. X      }
  1064. X    else
  1065. X    strcpy(to,from);
  1066. X    return (TRUE);
  1067. X  }
  1068. X
  1069. X/* =============================>>> gettcap  <<<============================= */
  1070. X  gettcap(cap,area)
  1071. X  char *cap, *area;
  1072. X  {
  1073. X    char **cpp, *cp;
  1074. X
  1075. X    cpp = &cp;        /* I think */
  1076. X    cp = area;
  1077. X    *area = 0;        /* assume null entry */
  1078. X
  1079. X    tgetstr(cap,cpp);    /* get the capability */
  1080. X    return (*area);        /* return 1st char */
  1081. X    
  1082. X  }
  1083. X
  1084. X/* =============================>>> tcapcs  <<<============================= */
  1085. X  tcapcs(str)
  1086. X  char *str;
  1087. X  {
  1088. X     /* send a termcap generated control string to terminal */
  1089. X
  1090. X    register char *cp;
  1091. X    int ttwt();
  1092. X
  1093. X    if (!(echof && !bakflg && !ttymode))
  1094. X    return;
  1095. X    if (!*str)        /* don't send null strings */
  1096. X    return;
  1097. X    cp = str;
  1098. X    tputs(cp,1,ttwt);
  1099. X
  1100. X  }
  1101. X
  1102. X/* =============================>>> tcapxy  <<<============================= */
  1103. X  tcapxy(x,y)
  1104. X  int x,y;
  1105. X  {
  1106. X    /* move cursor to x,y */
  1107. X
  1108. X   char *tgoto();
  1109. X
  1110. X   tcapcs(tgoto(Tcm,x-1,y-1));    /* send the string, adjusting x,y */
  1111. X
  1112. X  }
  1113. X#endif   /* termcap */
  1114. X
  1115. X
  1116. X/* =============================>>> ttinit  <<<============================= */
  1117. X  ttinit()
  1118. X  {
  1119. X#ifdef SYSV
  1120. X    struct termio nsgb;
  1121. X#else
  1122. X    struct sgttyb nsgb;
  1123. X    struct tchars ntch;
  1124. X    struct ltchars nltc;
  1125. X#endif
  1126. X
  1127. X#ifdef SCR_BUF
  1128. X    char *malloc();
  1129. X
  1130. X    /* malloc the screen buffer */
  1131. X    if ((Scrbuf = malloc(S_BUFSIZE)) == NULL)
  1132. X      {
  1133. X    reset();
  1134. X    remark("");
  1135. X    remark("tvx: cannot allocate screen buffer, aborting");
  1136. X    exit(999);
  1137. X      }
  1138. X    Scrptr = Scrbuf;
  1139. X#endif
  1140. X
  1141. X#ifdef SYSV
  1142. X    (void) Ioctl(0, TCGETA, &sgb);
  1143. X    (void) Ioctl(0, TCGETA, &nsgb);
  1144. X#else
  1145. X    (void) Ioctl(0, TIOCGETP, &sgb);
  1146. X    (void) Ioctl(0, TIOCGETP, &nsgb);
  1147. X    (void) Ioctl(0, TIOCGETC, &tch);
  1148. X    (void) Ioctl(0, TIOCGETC, &ntch);
  1149. X    (void) Ioctl(0, TIOCGLTC, <c);
  1150. X#endif
  1151. X
  1152. X#ifdef SYSV
  1153. X    nsgb.c_lflag &= ~(ECHO | ICANON);
  1154. X    nsgb.c_iflag &= ~(ICRNL | IXOFF);
  1155. X#else
  1156. X    nsgb.sg_flags |= CBREAK;
  1157. X    nsgb.sg_flags &= ~(CRMOD|ECHO|LCASE|TANDEM);
  1158. X#endif
  1159. X
  1160. X#ifdef SYSV
  1161. X    nsgb.c_cc[VMIN] = 1;    /* minimum characters */
  1162. X    nsgb.c_cc[VTIME] = -1;    /* time before read returns */
  1163. X#else
  1164. X    ntch.t_intrc = -1;  /* interrupt */
  1165. X    ntch.t_quitc = -1;  /* quit */
  1166. X    ntch.t_eofc = -1;   /* end-of-file */
  1167. X    ntch.t_brkc = -1;   /* input delimiter (like nl) */
  1168. X#endif
  1169. X
  1170. X/* the following two lines control flow control */
  1171. X
  1172. X#ifndef FLOWCONTROL
  1173. X#ifdef SYSV
  1174. X    nsgb.c_iflag &= ~(IXON | IXOFF);
  1175. X#else
  1176. X    ntch.t_startc = -1; /* start output */
  1177. X    ntch.t_stopc = -1;  /* stop output */
  1178. X#endif
  1179. X#endif
  1180. X
  1181. X#ifndef SYSV
  1182. X    nltc.t_suspc = -1;  /* stop process signal */
  1183. X    nltc.t_dsuspc = -1; /* delayed stop process signal */
  1184. X    nltc.t_rprntc = -1; /* reprint line */
  1185. X    nltc.t_flushc = -1; /* flush output (toggles) */
  1186. X    nltc.t_werasc = -1; /* word erase */
  1187. X    nltc.t_lnextc = -1; /* literal next character */
  1188. X#endif
  1189. X
  1190. X#ifdef SYSV
  1191. X    (void) Ioctl(0, TCSETA, &nsgb);
  1192. X#else
  1193. X    (void) Ioctl(0, TIOCSETP, &nsgb);
  1194. X    (void) Ioctl(0, TIOCSETC, &ntch);
  1195. X    (void) Ioctl(0, TIOCSLTC, &nltc);
  1196. X#endif
  1197. X
  1198. X#ifdef TERMCAP
  1199. X    gettermcap();            /* set up terminal characteristics */
  1200. X#endif
  1201. X
  1202. X    info.st_mode = -1;            /* no mode stuff yet */
  1203. X }
  1204. X
  1205. X
  1206. X#ifdef SCR_BUF
  1207. X/* =============================>>> ttflush  <<<============================= */
  1208. X  ttflush()
  1209. X  {
  1210. X    if (Scrptr != Scrbuf)
  1211. X    write(1, Scrbuf, Scrptr - Scrbuf);
  1212. X    Scrptr = Scrbuf;
  1213. X  }
  1214. X#endif
  1215. X
  1216. X/* =============================>>> ttrd_unix  <<<============================= */
  1217. X  ttrd_unix()
  1218. X  {
  1219. X           char c;
  1220. X
  1221. X    Read(0, &c, 1);
  1222. X    return(c);
  1223. X  }
  1224. X
  1225. X/* =============================>>> ttwtln  <<<============================= */
  1226. X  ttwtln(cbuf,cnt)
  1227. X  char *cbuf;
  1228. X  int cnt;
  1229. X  {
  1230. X#ifndef SCR_BUF
  1231. X    if (echof && !bakflg && !ttymode)
  1232. X    Write(1, cbuf, cnt);
  1233. X#else
  1234. X    if (echof && !bakflg && !ttymode)
  1235. X      {
  1236. X    while(cnt-- > 0)
  1237. X      {
  1238. X            if (Scrptr < Scrbuf + S_BUFSIZE)
  1239. X                *Scrptr++ = *cbuf++;
  1240. X            else
  1241. X          {
  1242. X                ttflush();
  1243. X                *Scrptr++ = *cbuf++;
  1244. X          }
  1245. X      }
  1246. X      }
  1247. X#endif
  1248. X  }
  1249. X
  1250. X/* =============================>>> ttwt  <<<============================= */
  1251. X  ttwt(c)
  1252. X  char c;
  1253. X  {
  1254. X    if (ttymode)
  1255. X    return;
  1256. X#ifndef SCR_BUF
  1257. X    Write(1, &c, 1);
  1258. X#else
  1259. X    if (Scrptr < Scrbuf + S_BUFSIZE)
  1260. X        *Scrptr++ = c;
  1261. X    else
  1262. X      {
  1263. X        ttflush();
  1264. X        *Scrptr++ = c;
  1265. X      }
  1266. X#endif
  1267. X  }
  1268. X
  1269. X/* =============================>>> ttclos  <<<============================= */
  1270. X  ttclos()
  1271. X  {
  1272. X
  1273. X#ifdef TERMCAP
  1274. X    char entry[80];
  1275. X
  1276. X    gettcap("te",entry);        /* cm end up string */
  1277. X    tcapcs(entry);            /* send it */
  1278. X#endif
  1279. X
  1280. X#ifdef SYSV
  1281. X    (void) Ioctl(0, TCSETA, &sgb);
  1282. X#else
  1283. X    (void) Ioctl(0, TIOCSETP, &sgb);
  1284. X    (void) Ioctl(0, TIOCSETC, &tch);
  1285. X    (void) Ioctl(0, TIOCSLTC, <c);
  1286. X#endif
  1287. X  }
  1288. X
  1289. X/* =============================>>> ttosinit  <<<============================= */
  1290. X  ttosinit()
  1291. X  {            /* need a special version for not doing termcap */
  1292. X#ifdef SYSV
  1293. X    struct termio nsgb;
  1294. X#else
  1295. X    struct sgttyb nsgb;
  1296. X    struct tchars ntch;
  1297. X    struct ltchars nltc;
  1298. X#endif
  1299. X
  1300. X    char entry[80];        /* scratch buffer for entry */
  1301. X
  1302. X#ifdef SYSV
  1303. X    (void) Ioctl(0, TCGETA, &sgb);
  1304. X    (void) Ioctl(0, TCGETA, &nsgb);
  1305. X#else
  1306. X    (void) Ioctl(0, TIOCGETP, &sgb);
  1307. X    (void) Ioctl(0, TIOCGETP, &nsgb);
  1308. X    (void) Ioctl(0, TIOCGETC, &tch);
  1309. X    (void) Ioctl(0, TIOCGETC, &ntch);
  1310. X    (void) Ioctl(0, TIOCGLTC, <c);
  1311. X#endif
  1312. X
  1313. X#ifdef SYSV
  1314. X    nsgb.c_lflag &= ~(ECHO | ICANON);
  1315. X    nsgb.c_iflag &= ~(ICRNL | IXOFF);
  1316. X#else
  1317. X    nsgb.sg_flags |= CBREAK;
  1318. X    nsgb.sg_flags &= ~(CRMOD|ECHO|LCASE|TANDEM);
  1319. X#endif
  1320. X
  1321. X#ifdef SYSV
  1322. X    nsgb.c_cc[VMIN] = 1;    /* minimum characters */
  1323. X    nsgb.c_cc[VTIME] = -1;    /* time before read returns */
  1324. X#else
  1325. X    ntch.t_intrc = -1;  /* interrupt */
  1326. X    ntch.t_quitc = -1;  /* quit */
  1327. X    ntch.t_eofc = -1;   /* end-of-file */
  1328. X    ntch.t_brkc = -1;   /* input delimiter (like nl) */
  1329. X#endif
  1330. X
  1331. X/* the following two lines control flow control */
  1332. X
  1333. X#ifndef FLOWCONTROL
  1334. X#ifdef SYSV
  1335. X    nsgb.c_iflag &= ~(IXON | IXOFF);
  1336. X#else
  1337. X    ntch.t_startc = -1; /* start output */
  1338. X    ntch.t_stopc = -1;  /* stop output */
  1339. X#endif
  1340. X#endif
  1341. X
  1342. X#ifndef SYSV
  1343. X    nltc.t_suspc = -1;  /* stop process signal */
  1344. X    nltc.t_dsuspc = -1; /* delayed stop process signal */
  1345. X    nltc.t_rprntc = -1; /* reprint line */
  1346. X    nltc.t_flushc = -1; /* flush output (toggles) */
  1347. X    nltc.t_werasc = -1; /* word erase */
  1348. X    nltc.t_lnextc = -1; /* literal next character */
  1349. X#endif
  1350. X
  1351. X#ifdef SYSV
  1352. X    (void) Ioctl(0, TCSETA, &nsgb);
  1353. X#else
  1354. X    (void) Ioctl(0, TIOCSETP, &nsgb);
  1355. X    (void) Ioctl(0, TIOCSETC, &ntch);
  1356. X    (void) Ioctl(0, TIOCSLTC, &nltc);
  1357. X#endif
  1358. X
  1359. X#ifdef TERMCAP
  1360. X#ifdef USE_TC_is
  1361. X    gettcap("is",entry);        /* initialization string */
  1362. X    tcapcs(entry);            /* send the intialization string */
  1363. X#endif
  1364. X
  1365. X    gettcap("ti",entry);        /* cm initialization string */
  1366. X    tcapcs(entry);            /* send the intialization string */
  1367. X#endif
  1368. X }
  1369. X
  1370. X/* ==========================>>> unix_sys  <<<============================= */
  1371. X  unix_sys()
  1372. X  {
  1373. X    char rp[150];
  1374. X    int oldtty;
  1375. X
  1376. X    tvclr();            /* clear the screen */
  1377. X    oldtty = ttymode; ttymode = FALSE;
  1378. XDO_UNIX:
  1379. X    remark("Unix command interface"); remark("");
  1380. X    remark("Enter Unix command line: ");
  1381. X    reply(rp,149);
  1382. X    reset();        /* reset terminal to unix mode */
  1383. X
  1384. X    system(rp);
  1385. X
  1386. X    ttosinit();        /* reset terinal to our mode */
  1387. X
  1388. X    remark("");
  1389. X    remark("");
  1390. X
  1391. X    prompt("Any key to continue with edit (! for another Unix command): ");
  1392. X    reply(rp,1);
  1393. X
  1394. X    trmini();        /* this has to be here or screen is cleared! */
  1395. X    if (*rp == '!')
  1396. X    goto DO_UNIX;
  1397. X
  1398. X    ttymode = oldtty;
  1399. X    verify(1);
  1400. X  }
  1401. X
  1402. X/* =============================>>> get_mode <<<============================= */
  1403. X  get_mode(f)
  1404. X  FILE *f;
  1405. X  {        /* gets access mode of open file f */
  1406. X
  1407. X    char rp[10];
  1408. X
  1409. X    info.st_mode = -1;    /* assume no mode */
  1410. X
  1411. X    if (newfil)
  1412. X    return;
  1413. X    if (fstat(fileno(f),&info) != 0)
  1414. X      {
  1415. X    info.st_mode = -1;    /* assume no mode */
  1416. X    return;
  1417. X      }
  1418. X    info.st_mode &= 07777;    /* zap extraneous stuff*/
  1419. X    if (((info.st_mode & 0222) == 0) || rdonly)    /* no write permission */
  1420. X      {
  1421. X    prompt("No write permission for file, edit R/O? (y/n) ");
  1422. X    ureply(rp,1);
  1423. X    if (*rp == 'Y')
  1424. X        rdonly = TRUE;
  1425. X    else
  1426. X      {
  1427. X        reset();
  1428. X        exit(999);
  1429. X      }
  1430. X      }
  1431. X  }
  1432. X
  1433. X/* =============================>>> set_mode <<<============================= */
  1434. X  set_mode(f)
  1435. X  FILE *f;
  1436. X  {        /* sets access mode of open file f */
  1437. X#ifdef SYSV
  1438. X    if (newfil)
  1439. X    return;
  1440. X    else
  1441. X    tverrb("Unable to set file mode, umask will be used.");
  1442. X    return;    /* The person doing the port to System V removed the
  1443. X    fchmod code.  It may not apply to System V, but was needed on
  1444. X    the BSD version to keep executable shell scripts executable.
  1445. X    (among other things - that is the most obvious reason)
  1446. X    Maybe someone knows if this is needed on System V.  BEW 2/11/86 */
  1447. X#else
  1448. X    if (newfil || info.st_mode == -1)
  1449. X    return;
  1450. X#ifndef ULTRIX11
  1451. X    if (fchmod(fileno(f),info.st_mode) != 0)
  1452. X#endif
  1453. X    tverrb("Unable to set file mode, umask will be used.");
  1454. X#endif
  1455. X  }
  1456. X
  1457. X/* ==========================>>> expand_name <<<============================ */
  1458. X  expand_name(n)
  1459. X  char *n;
  1460. X  {        /* expands unix file names */
  1461. X    char tmp[FNAMESIZE+1];
  1462. X
  1463. X    if ((*n == '~') && (n[1] == '/'))
  1464. X      {
  1465. X    strcpy(tmp,getenv("HOME"));
  1466. X    scopy(n,1,tmp,strlen(tmp));
  1467. X    strcpy(n,tmp);
  1468. X      }
  1469. X  }
  1470. X
  1471. X/* =============================>>> ren_file <<<=========================== */
  1472. X  ren_file(old,new)
  1473. X  char *old, *new;
  1474. X  {
  1475. X    int pid;
  1476. X    static char *mvarg[4];
  1477. X    static int status;
  1478. X
  1479. X    if (rename(old,new) != 0)
  1480. X      {
  1481. X    mvarg[0] = "/bin/mv";
  1482. X    mvarg[1] = old;
  1483. X    mvarg[2] = new;
  1484. X    mvarg[3]=0;
  1485. X    pid=fork();
  1486. X    if (pid == 0)
  1487. X      {
  1488. X        execve("/bin/mv",mvarg,environ);
  1489. X            tverrb("Error trying to start mv utility");
  1490. X        _exit(999);
  1491. X      }
  1492. X    wait(&status);
  1493. X    if (status > 255)        /* error return */
  1494. X      {
  1495. X        prompt(old) ; prompt(" not renamed to "); remark(new);
  1496. X        prompt("Edited file found as: "); remark(old);
  1497. X      }
  1498. X      }
  1499. X  }
  1500. X
  1501. X/* =============================>>> temp_name <<<=========================== */
  1502. X  temp_name(n,first)
  1503. X  char *n;
  1504. X  int first;
  1505. X  {
  1506. X    /* generates a temporary name from n.  Depending on value of
  1507. X       first, it will either add a 1 or 2 to name */
  1508. X    SLOW int i;
  1509. X
  1510. X#ifdef USETMP
  1511. X    SLOW char pidno[20];
  1512. X    long pidint;
  1513. X
  1514. X    if (first)            /* create full temp name */
  1515. X      {
  1516. X    *n = 0;
  1517. X    pidint=getpid();
  1518. X    itoa(pidint,pidno);
  1519. X    strcpy(n,"/tmp/tvx1");
  1520. X    scopy(pidno,0,n,9);
  1521. X      }
  1522. X    else            /* alternate between 1 and 2 */
  1523. X      {
  1524. X    if (n[8] == '1')
  1525. X        n[8] = '2';
  1526. X    else
  1527. X        n[8] = '1';
  1528. X      }
  1529. X#else
  1530. X    if (first)
  1531. X      {
  1532. X    if ((i = rindx(n,FILESEP)) > 0)    /* see if extenstion */
  1533. X        scopy(TEMPEXT,0,n,i);        /* make .bak */
  1534. X    else
  1535. X      {
  1536. X        scopy(TEMPEXT,0,n,strlen(n));    /* just add on */
  1537. X      }
  1538. X      }
  1539. X    else
  1540. X      {
  1541. X    i = strlen(n);
  1542. X    if (n[i-1] == '1')
  1543. X        n[i-1] = '2';
  1544. X    else
  1545. X        n[i-1] = '1';
  1546. X      }
  1547. X#endif
  1548. X  }
  1549. X
  1550. X#ifndef SUN
  1551. X/* =============================>>> USER_1 <<<============================= */
  1552. X  user_1(knt)
  1553. X  int knt;
  1554. X  {
  1555. X    knt = 0;
  1556. X    return (TRUE);
  1557. X  }
  1558. X
  1559. X#else
  1560. X/* =============================>>> USER_1 <<<============================= */
  1561. X  user_1(knt)
  1562. X  int knt;
  1563. X  {
  1564. X    /* for suns, re-initialize window */
  1565. X#ifdef TERMCAP
  1566. X    gettermcap();        /* set up terminal characteristics */
  1567. X    tvidefs();        /* and reset defs */
  1568. X#endif
  1569. X    verify(1);
  1570. X    return (TRUE);
  1571. X  }
  1572. X#endif
  1573. X
  1574. X/* =============================>>> USER_2 <<<============================= */
  1575. X  user_2(knt)
  1576. X  int knt;
  1577. X  {
  1578. X    knt = 0;
  1579. X    return (TRUE);
  1580. X  }
  1581. X
  1582. X#ifdef SYSV
  1583. X/* ============================>>> RENAME <<<============================ */
  1584. X  rename(from, to)
  1585. X  char *from, *to;
  1586. X  {
  1587. X    if (access(from, 00) != 0 || access(to, 02) != 0)
  1588. X    return(-1);
  1589. X    unlink(to);
  1590. X    return(link(from, to));
  1591. X  }
  1592. X#endif
  1593. X#ifdef PRO350
  1594. X/* =============================>>> rename <<<============================= */
  1595. X  rename(old, new)
  1596. X  char *old;
  1597. X  char *new;
  1598. X  {
  1599. X    int res;
  1600. X
  1601. X    if ((res = link(old, new)) < 0)
  1602. X    return (res);
  1603. X    else
  1604. X    unlink(old);
  1605. X    return (0);
  1606. X  }
  1607. X#endif
  1608. X/* -------------------------- tvx_unix.c ------------------------------ */
  1609. SHAR_EOF
  1610. echo ALL DONE!
  1611. exit 0
  1612.  
  1613.